package com.tvunetworks.center.user.service;

import com.github.pagehelper.PageInfo;
import com.tvunetworks.center.common.model.*;
import com.tvunetworks.center.common.model.dto.user.DeviceBelongUserDTO;
import com.tvunetworks.center.common.model.param.ListUserPeerIdsParam;
import com.tvunetworks.center.common.model.vo.ChannelUsingCount;
import com.tvunetworks.center.common.util.Result;
import com.tvunetworks.center.gs.model.Device;
import com.tvunetworks.center.gs.model.DeviceExtend;
import com.tvunetworks.center.user.model.OwnerByListPeerIdParam;
import com.tvunetworks.center.user.model.PageInfoBookMarkParam;
import com.tvunetworks.center.user.model.UserDevice;
import com.tvunetworks.center.user.model.json.RExtRelation;
import com.tvunetworks.center.user.model.json.VoDevice;
import com.tvunetworks.center.user.model.param.*;
import com.tvunetworks.center.user.model.vo.*;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @author HenryChen
 * @program:
 * @description:
 * @create: 5/29/2019 1:05 PM
 **/
public interface UserDeviceService {

    /**
     * RC页面查询R列表,并按照条件排序
     *
     * @param userId userId
     * @param param  param
     * @return List
     */
    List<Device> listReceiverControlR(String userId, SearchDeviceParam param);

    /**
     * RC页面查询R列表,并且将用户上一次使用的R放在第一个
     * 从 advancedControlWithInit 接口获取上一次使用的 R
     * 目前有两个版本一个是初始版本，advancedControlWithInit
     * 另一个是v2版本的API v2/advancedControlWithInit
     * 用 remark 区分开
     *
     * @param userId userId
     * @param param  param
     * @param remark remark
     * @return ListRResult
     */
    ListRResult listReceiverControlRAndLastUsed(String userId, SearchDeviceParam param, String remark);


    /**
     * RC页面查询R列表,并且将用户上一次使用的R放在第一个
     * 从 advancedControlWithInit 接口获取上一次使用的 R
     *
     * @param userId userId
     * @param param  param
     * @return ListRResult
     */
    ListRResult listReceiverControlRAndLastUsed(String userId, SearchDeviceParam param);


    /**
     * Home 页面查询用户下的R
     *
     * @param userId userId
     * @param param  param
     * @return PageInfo
     */
    PageInfo<Device> pageR(String userId, SearchDeviceParam param);

    /**
     * RC页面查询Source列表
     *
     * @param userId userId
     * @param param  param
     * @return List
     */
    List<Device> listReceiverControlSource(String userId, SearchDeviceParam param);

    /**
     * @param userId userId
     * @param param  param
     * @return PageInfo
     */
    PageInfo<Device> pageReceiverControlSource(String userId, SearchDeviceParam param);


    /**
     * My Source 页面查询source
     *
     * @param userId userId
     * @param param  param
     * @return List
     */
    List<Device> listMySource(String userId, SearchDeviceParam param);

    /**
     * 根据 {@link UserDeviceService#listMySource(java.lang.String, com.tvunetworks.center.common.model.SearchDeviceParam)}
     * 的结果进行分页
     *
     * @param userId userId
     * @param param  param
     * @return PageInfo
     */
    PageInfo<Device> pageMySource(String userId, SearchDeviceParam param);

//    List<String> listUserDevice(String userId, List<String> types, String condition);

//    /**
//     * @param userId
//     * @param rid 如果rid存在，那么查询的就是R对应的source，token需要查询这个R的token，否则查询所有R的token
//     * @param param
//     * @return
//     */
//    List<String> listUserPeerIds(String userId, String rid, SearchDeviceParam param);


    /**
     * 查询用户下的source id，根据 listAllUserSourceIds 查询出来的结果过滤状态
     *
     * @param userId 用户的id
     * @param param  过滤条件
     * @return 返回的是source 的 id 集合
     */
    List<String> listUserSourceIds(String userId, SearchDeviceParam param);


    /**
     * 查询用户下的source,
     * <p>
     * 条件:
     * 1.会过滤 source 的类型和 bookmark
     * 2.但是不会过滤 source 的状态
     * 3.如果 {@link SearchDeviceParam#receiver} 为 true 则说明想查用户下的 R，否则就是查 source
     * 4.{@link SearchDeviceParam#rid} 为 null 则查用户下的source,否则查 rid 下的 source
     * <p>
     * 如果你不打算过滤设备的状态可以调用此方法
     *
     * @param userId 用户的id
     * @param param  过滤条件
     * @return 返回的是 source 的 id 集合
     */
    Set<String> listUnfilteredStatusUserSourceIds(String userId, SearchDeviceParam param);


    /**
     * 查询用户下的 source 完整信息,根据 listAllUserSourceIds 查询出来的结果过滤设备的状态
     *
     * @param userId 用户的id
     * @param param  过滤条件
     * @return 返回source的完整 device 信息集合
     */
    List<Device> listUserSourceDevices(String userId, SearchDeviceParam param);

    /**
     * 列出用户的设备，过滤类型和condition
     *
     * @param userId userId
     * @param param  param
     * @return List
     */
    List<String> listUserPeerIdFilterByTypeAndCondition(String userId, SearchDeviceParam param);

    /**
     * @param userId userId
     * @return List
     */
    List<String> listUserRids(String userId);

    /**
     * @param userId userId
     * @return List
     */
    List<String> listUserTids(String userId);

    /**
     * @param userId userId
     * @return List
     */
    List<String> listUserXids(String userId);

    /**
     * @param userId userId
     * @return List
     */
    List<String> listUserDeviceIds(String userId);

    /**
     * @param userId userId
     * @return List
     */
    List<String> listUserCacheRids(String userId);

    /**
     * @param userId userId
     * @return List
     */
    List<String> listUserCacheTids(String userId);

    /**
     * @param userId userId
     * @return List
     */
    List<String> listUserCacheXids(String userId);

    /**
     * @param userId userId
     * @return List
     */
    List<String> listUserCacheDeviceIds(String userId);

    /**
     * 查询设备属于的用户，如果是 Anywhere，那么需要加上 Token
     *
     * @param peerId peerId
     * @return List
     */
    List<String> listCacheDeviceBelongUser(String peerId);

    /**
     * Share 页面查询正在live的R的设备信息
     *
     * @param userId    userId
     * @param condition condition
     * @return List
     */
    List<Device> listLiveRInfo(String userId, String condition);

    /**
     * 根据用户查询，用户名下的R,并缓存起来，在使用的时候注意不可以更改返回对象的list，
     * 因为是java 对象，修改 list 会导致引用被改变
     *
     * @param userId userId
     * @return List
     */
    List<String> listCacheRPeerId(String userId);


    /**
     * My Source 页面查询source可以使用的R (用户下的和配对的R)
     * <p>
     * 可用的R包括用户的R和配对的R的交集
     *
     * @param userId userId
     * @param param  param
     * @return List
     */
    List<Device> listSourceAvailableR(String userId, SearchSourcePairedRParam param);

    /**
     * My Source 页面查询source可以使用的R (用户下的和配对的R)
     * <p>
     * 可用的R包括用户的R和配对的R的交集
     *
     * @param userId userId
     * @param param  param
     * @return List
     */
    List<Device> listSourceAvailableRSort(String userId, SearchSourcePairedRParam param);

    /**
     * @param userId     userId
     * @param sourceId   sourceId
     * @param sourceType sourceType
     * @param condition  condition
     * @return List
     */
    List<String> listSourceAvailableRids(String userId, String sourceId, String sourceType, String condition);

    /**
     * 分页查询 My Source 页面查询source可以使用的R (用户下的和配对的R)
     *
     * @param userId userId
     * @param param  分页 排序条件等
     * @return PageInfo
     */
    PageInfo<Device> pageSourceAvailableR(String userId, SearchSourcePairedRParam param);

    /**
     * 分页查询 My Source 页面查询source可以使用的R (用户下的和配对的R)
     *
     * @param userId userId
     * @param param  分页 排序条件等
     * @return PageInfo
     */
    PageInfo<Device> pageSourceAvailableRSort(String userId, SearchSourcePairedRParam param);


    /**
     * 从数据库查询用户下所有的R 只包含R的peerId 和 name,不包含状态
     *
     * @param userId userId
     * @param param  分页等查询条件
     * @return PageInfo
     */
    PageInfo<SimpleDeviceVo> pageAllUserRNoStatus(String userId, SearchSourcePairedRParam param);

    /**
     * @param userId    userId
     * @param condition condition
     * @param mapType   mapType
     * @return List
     */
    List<DevicePositionVo> listUserSourcePosition(String userId, String condition, String mapType);

    /**
     * @param sourceId sourceId
     * @return List
     */
    List<DevicePositionVo> getSourceLiveRPosition(String sourceId);


    /**
     * websocket task info
     *
     * @param userId 用户id
     * @param param  需要处理的deice
     * @return List
     */
    List<DeviceExtend> listCurrentDeviceForTaskInfo(String userId, ListDeviceParam param);

    /**
     * Setting页面查询用户已绑定的设备
     *
     * @param param  param
     * @param userId userId
     * @return List
     */
    List<SearchUserDeviceVo> listSettingPageUserBindDevice(String userId, SearchUserDeviceParam param);

    /**
     * Setting页面查询用户可以绑定的设备
     *
     * @param param param
     * @return List
     */
    List<SearchUserDeviceVo> listSettingPageUserCanBindDevice(SearchUserDeviceParam param);

    /**
     * setting页面 查询另一个用户的设备，用于分配给某个账号
     *
     * @param userId userId
     * @param email  email
     * @return List
     */
    List<SearchUserDeviceVo> listSettingPageUserCanBindDeviceByUserName(String userId, String email);

    /**
     * setting页面 通过SalesForce查询设备，用于分配给某个账号
     *
     * @param userId  userId
     * @param account account
     * @return List
     */
    List<SearchUserDeviceVo> listCanBindDeviceBySalesForce(String userId, String account);

    /**
     * Setting页面分配可绑定的设备时，查询某个设备配对的设备
     *
     * @param userId userId
     * @param peerId peerId
     * @return List
     */
    List<SearchUserDeviceVo> listSettingPageUserPairedDevice(String userId, String peerId);


    /**
     * 未用户添加移除设备
     *
     * @param userId           userId
     * @param addPeerIds       addPeerIds
     * @param addOwnPeerIds    addOwnPeerIds
     * @param removeOwnPeerIds removeOwnPeerIds
     * @param loginUserId      loginUserId
     * @param removePeerIds    removePeerIds
     */
    void correlateUserDevice(String userId, String addPeerIds, String removePeerIds, String addOwnPeerIds, String removeOwnPeerIds, String loginUserId);

    /**
     * 绑定或解绑用户和设备关系
     * @param userId           userId
     * @param addPeerIds       addPeerIds
     * @param removePeerIds    removePeerIds
     * @param addOwnPeerIds    addOwnPeerIds
     * @param removeOwnPeerIds removeOwnPeerIds
     * @param loginUserId      loginUserId
     * @param relateSource     relateSource
     */
    void correlateUserDevice(String userId, String addPeerIds, String removePeerIds, String addOwnPeerIds, String removeOwnPeerIds, String loginUserId, boolean relateSource);

    /**
     * 是否有用户绑定过这些设备，用于绑定设备之前的check
     *
     * @param addPeerIds addPeerIds
     * @return boolean
     */
    boolean existUserBindDevice(String addPeerIds);

    /**
     * 用户是否绑定该设备
     *
     * @param userId userId
     * @param peerId peerId
     * @return boolean
     */
    boolean isUserOwnDevice(String userId, String peerId);

    /**
     * 列出和设备有绑定关系的用户
     *
     * @param peerId peerId
     * @return List
     */
    List<BindDeviceUserVo> listDeviceBindUser(String peerId);

    /**
     * @param param param
     * @return PageInfo
     */
    PageInfo<ExtVo> pageUserExt(PageExtParam param);

    /**
     * @param peerId peerId
     */
    void removeUserDevice(String peerId);

    /**
     * @param userIdArr userIdArr
     * @param peerId    peerId
     * @throws Exception 编译
     */
    void removeDevivecBindUser(String userIdArr, String peerId) throws Exception;

    /**
     * @param userIdArr    userIdArr
     * @param peerId       peerId
     * @param relateSource relateSource
     * @throws Exception 编译
     */
    void removeDevivecBindUser(String userIdArr, String peerId, boolean relateSource) throws Exception;

    /**
     * @param userIdArr    userIdArr
     * @param peerId       peerId
     * @param relateSource relateSource
     * @return int
     * @throws Exception 编译
     */
    int addDeviceBindUser(String userIdArr, String peerId, boolean relateSource) throws Exception;

    /**
     * @param userId    userId
     * @param condition condition
     * @param types     types
     * @return List
     */
    List<String> listUserDevice(String userId, String condition, String types);

    /**
     * 版权归属：2019-TUVNETWORKS
     * 项目名：tvucc-user
     * 类名：UserDeviceService
     * 方法名：queryTokenDeviceList
     * 描述:TODO<p>根据设备id或者名称，获取token device的设备</p>
     * 创建人：Gabrielliu(lk)
     * 创建时间：Oct 28, 2019 11:30:31 AM
     * 修改人：
     * 修改时间：
     * 修改备注：
     *
     * @param loginUser    loginUser
     * @param peerIdOrName peerIdOrName
     * @param userId       userId
     * @return Result
     * @throws Exception Object
     */
    Result<Object> queryTokenDeviceList(LoginUser loginUser, String peerIdOrName, String userId) throws Exception;

    /**
     * User 是否是 Device 的 Owner 针对于 Grid
     * 2022 /5/27  针对Grid ,Pack,Anywhere 都可校验Owner权限
     * @param userId userId
     * @param peerId peerId
     * @return boolean
     */
    boolean isUserOwner(String userId, String peerId);

    /**
     * 为所有拥有 oldPeerId 的用户添加 newPeerId
     *
     * @param oldPeerId  oldPeerId
     * @param newPeerId  newPeerId
     * @param gridSource gridSource
     * @param deleteOld  deleteOld
     * @param taskId     taskId
     * @return int
     */
    int copyDeviceToNewDevice(String oldPeerId, String newPeerId, boolean gridSource, boolean deleteOld, String taskId);

    /**
     * @param userId userId
     * @param peerId peerId
     * @return boolean
     */
    boolean isUserDeviceExist(String userId, String peerId);

    /**
     * @param userId userId
     * @param peerId peerId
     */
    void addUserDevice(String userId, String peerId);

    /**
     * @param userId userId
     * @param peerId peerId
     */
    void removeUserDevice(String userId, String peerId);

    /**
     * @param user user
     * @return List
     * @throws Exception 编译
     */
    List<VoDevice> getUnBindVoReceiverList(LoginUser user) throws Exception;

    /**
     * @param user user
     * @return List
     * @throws Exception 编译
     */
    List<String> getAllLivePeerIdList(LoginUser user) throws Exception;

    /**
     * @param userId userId
     * @return List
     */
    List<String> listOwnerPeerIds(String userId);

    /**
     * 批量查询 GridTokenStatus
     *
     * @param userId  userId
     * @param peerIds peerIds
     * @return Map  key:peerId value:gridStatus
     */
    Map<String, Integer> batchGetGridTokenStatus(String userId, List<String> peerIds);

    /**
     * @param peerId peerId
     * @return DeviceBelongUserDTO
     */
    DeviceBelongUserDTO listDeviceBelongUserForAlertDeviceChange(String peerId);

    /**
     * @param userId userId
     * @param manual manual
     * @return ChannelUsingCount
     */
    ChannelUsingCount channelCount(String userId, boolean manual);

    /**
     * @param param param
     * @return PageInfo
     */
    PageInfo<Device> pageBookingChannel(PageBookingChannelParam param);

    // ********************* Device Copy Start *********************

    /**
     * @param oldPeerId oldPeerId
     * @param newPeerId newPeerId
     * @param taskId    taskId
     * @return Result
     */
    Result<String> checkCopy(String oldPeerId, String newPeerId, String taskId);

    /**
     * @param oldPeerId oldPeerId
     * @param newPeerId newPeerId
     * @param taskId    taskId
     * @return Result
     */
    Result<String> copyDevice(String oldPeerId, String newPeerId, String taskId);

    /**
     * @param peerId peerId
     * @param taskId taskId
     * @return Result
     */
    Result<String> deleteDevice(String peerId, String taskId);


    // ********************* Device Copy end *********************

    /**
     * 查询用户下的 source 完整信息,根据 listAllUserSourceIds 查询出来的结果过滤设备的状态
     *
     * @param userId 用户的id
     * @param param  过滤条件
     * @return 返回source的完整 device 信息集合
     */
    Map<String, Object> groupForAdvanceControl(String userId, SearchDeviceParam param);

    /**
     * @param param param
     * @return List
     */
    List<String> listUserPeerIds(ListUserPeerIdsParam param);

    /**
     * @param userId                userId
     * @param rid                   rid
     * @param tokenRegardlessOfUser tokenRegardlessOfUser
     * @param condition             condition
     * @param excludeFlag           excludeFlag
     * @return List
     */
    List<String> getTokenAnywhereIds(String userId, String rid, boolean tokenRegardlessOfUser, String condition, boolean excludeFlag);

    /**
     * @param rid rid
     * @return Result
     * @throws Exception 编译
     */
    Result<String> getRSourceTypeList(String rid) throws Exception;

    /**
     * @param email         email
     * @param loginUserId   loginUserId
     * @param operationType operationType
     * @param param         param
     */
    void saveUserDeviceRecord(String email, String loginUserId, String operationType, Map param);

    /**
     * @param peerId peerId
     */
    void deleteGrid(String peerId);

    /**
     * 获取用户下指定的设备集合
     *
     * @param userId 用户id
     * @param param 参数
     * @return 返回device的集合
     */
    List<Device> listDeviceOfUser(String userId, SearchDeviceParam param);

    /**
     * @param param param
     * @return List
     */
    List<Device> listUserDevice(PageUserDeviceParam param);

    /**
     * @param userId userId
     */
    void removeUserAllDevice(String userId);

    /**
     * @param param param
     * @return PageInfo
     */
    PageInfo<Device> pageUserUnbindRPairedSource(PageUserUnbindRPairedSourceParam param);

    /**
     * @param message message
     * @throws IOException 编译异常
     */
    void notifyDevicePairChange(String message) throws IOException;

    /**
     * @param loginUser loginUser
     * @param param     param
     */
    void reloadUser(LoginUser loginUser, ReloadUserParam param);

    /**
     * @param loginUser loginUser
     * @param rids      rids
     */
    void reloadReceiver(LoginUser loginUser, List<String> rids);

    /**
     * @param param param
     * @return PageInfo
     */
    PageInfo<SearchUserDeviceVo> pageUserRPairedSource(PageUserRPairedSourceParam param);

    /**
     * resetOwner
     */
    void resetOwner();

    /**
     * @return List
     */
    List<RExtRelation> listNeedResetRExt();

    /**
     * @param list list
     */
    void resetRExt(List<RExtRelation> list);

    /**
     * 通过userId获取该用户下所有的R
     *
     * @param userId    userId
     * @param condition condition
     * @return List
     */
    List<SearchUserDeviceVo> getReceiverListByUserId(String userId, String condition);

    /**
     * 给用户绑定或解绑pack和anywhere
     *
     * @param userId          userId
     * @param operationUserId operationUserId
     * @param addPeerIds      addPeerIds
     * @param removePeerIds   removePeerIds
     * @param serviceName     serviceName
     * @return String
     */
    String bingUserPackAndAnywhere(String userId, String operationUserId, List<String> addPeerIds, List<String> removePeerIds, String serviceName);

    /**
     * 给多个用户绑定以R为中心的Receive
     *
     * @param operationUserId operationUserId
     * @param peerIds         peerIds
     * @param userIds         userIds
     * @return String
     */
    String bindUserReceiverCenter(String operationUserId, List<String> peerIds, List<String> userIds);

    /**
     * 给多个用户解绑以R为中心的Receive
     *
     * @param operationUserId operationUserId
     * @param peerIds         peerIds
     * @param userIds         userIds
     * @return String
     */
    String unbindUserReceiverCenter(String operationUserId, List<String> peerIds, List<String> userIds);

    /**
     * 分页查询R下所有的source
     *
     * @param param param
     * @return PageInfo
     */
    PageInfo<Device> pageRPairedSource(PageUserUnbindRPairedSourceParam param);

    /**
     * 用户用户下所有的R以及该R是否含有globalGridFeature
     *
     * @param userId userId
     * @param param  param
     * @return PageInfo
     */
    PageInfo<FeatureDeviceVo> pageAllUserRWithGlobalGridFeature(String userId, SearchSourcePairedRParam param);


    /**
     * @param userId                userId
     * @param pageInfoBookMarkParam pageInfoBookMarkParam
     * @return Result
     * @throws Exception 编译异常
     */
    //分页查询bookmark
    Result<PageInfo<PageInfoBookMarkParam>> pageInfoBookMark(String userId, PageInfoBookMarkParam pageInfoBookMarkParam) throws Exception;

    /**
     * @param userId     userId
     * @param bookmarkId bookmarkId
     * @param status     status
     * @param search     search
     * @param pageSize   pageSize
     * @param pageNum    pageNum
     * @return Result
     * @throws Exception 编译
     */
    //在bookmark下分页查询R
    Result<PageInfo<Device>> pageInfoRByBookMark(String userId, String bookmarkId, List<String> status, String search, Integer pageSize, Integer pageNum) throws Exception;

    /**
     * @param bookmarkId bookmarkId
     * @return List
     * @throws Exception 编译
     */
    //查询bookmark下的R
    List<String> selectRByBookmarkId(String bookmarkId) throws Exception;

    /**
     * @param param param
     * @return Result
     * @throws Exception 编译
     */
    Result startAllByBookMarkId(PageInfoRByBookMarkParam param) throws Exception;

    /**
     * @param bookmarkId bookmarkId
     * @return Result
     * @throws Exception 编译
     */
    Result stopAllByBookMarkId(String bookmarkId) throws Exception;

    /**
     * @param user       user
     * @param bookmarkId bookmarkId
     * @param activeNum  activeNum
     * @return Result
     */
    Result getAllChildBookmarkTreeWithDevice(LoginUser user, String bookmarkId, String activeNum);

    /**
     * 查询该用户下有TimeLock的feature的receiver集合
     *
     * @param userId 用户id
     * @param param  查询条件
     * @return 满足的集合
     */
    List<Device> listReceiverByTimeLockFeature(String userId, SearchDeviceParam param);

    /**
     * 查询该用户下指定R配对的有TimeLock的feature的Pack集合
     *
     * @param userId 用户id
     * @param param  查询条件
     * @return 满足的集合
     */
    PageInfo<Device> listPackByTimeLockFeature(String userId, TimeLockPackParam param);

    /**
     * 校验该设备是否在该用户下属于owner
     *
     * @param userId userId
     * @param peerId souceId
     * @return true:owner,false:non-owner
     */
    boolean checkSourceIsOwnerByUserId(String userId, String peerId);

    /**
     * 根据userId获取该用户下所有的ext
     *
     * @param userId    用户id
     * @param condition 条件
     * @return 所有的ext
     */
    List<String> listExtByUserId(String userId, String condition);


    /**
     * @param userId    userId
     * @param condition condition
     * @return java.util.List<java.lang.String>
     * @throws Exception if has error
     * @author KevinLi
     * @date 12/6/2021
     */
    List<String> listOwnerGridId(String userId, String condition);

    /**
     * 查询用户下拥有owner的Pack和X
     * @param userId userId
     * @param condition condition
     * @return 拥有owner权限的x或者Pack
     */
    List<String> listOwnerXAndPackId(String userId, String condition);

    /**
     * 添加用户和R绑定关系,包括R下的X和T
     * @param userId 用户id
     * @param rid rid
     * @return 是否成功
     */
    Result bingUserAndReceiver(String userId, String rid);
    /**
     * 删除用户和R绑定关系,包括R下的X和T
     * @param userId 用户id
     * @param rid rid
     * @return 是否成功
     */
    Result deleteUserAndReceiver(String userId, String rid);

    /**
     * 获取所有用户下子账号的脏数据
     * @return 返回脏数据
     */
    Map<String, List<UserDevice>> listUserDeviceOfDirtyData();

    /**
     * 删除userDevice中的脏数据
     * @param userId 用户id
     * @param index index
     * @return 返回删除的脏数据
     */
    List<UserDevice> deleteDirtyData(String userId, int index);

    /**
     * 根据用户删除tvu_user_device表里的脏数据
     * @param email email
     * @return 刪除的脏数据
     */
    List<UserDevice> deviceDeleteByEmail(String email);

    /**
     * 给用户授权Grid,如果用户已经有权限,则返回已拥有,没权限则授权
     * @param userId userId
     * @param gridId gridId
     * @return 是否成功
     */
    Result<String> setGridByUserId(String userId, String gridId);

    /**
     * 给Anywhere授权owner权限
     * @param param param
     * @param loginUser loginUser
     */
    void correlateAnywhere(AnywhereParam param, LoginUser loginUser);
    /**
     * 查询用户下拥有owner的Pack
     * @param userId userId
     * @param condition condition
     * @return 拥有owner权限的Pack
     */
    List<String> listOwnerPackId(String userId, String condition);
    /**
     * 查询用户下拥有owner的Anywhere
     * @param userId userId
     * @param condition condition
     * @param rid rid
     * @return 拥有owner权限的Pack
     */
    List<String> pageOwnerAnywhere(String userId, String condition, String rid);

    /**
     *  根据用户id和peerid查询在tvu-token-device表中是否为owner权限
     * @param loginUser loginUser
     * @param param param
     * @return  Result
     */
    Result isUserOwnerByListPeerId(LoginUser loginUser,OwnerByListPeerIdParam param);

}
